package com.tangyuan.observer;

/**
 * @Author tangyuan
 * @Description:电视展示平台，当气象台的数据发生变化时，这里即时响应。
 * @Data 2018/4/5
 */
public class TVDisplay implements Observer, DisplayElement{
    private Subject weatherData;
    private float temperature;

    public TVDisplay(Subject weatherData){
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }

    @Override
    public void display(Object o) {
        System.out.println("TVDisplay 正在播放现在气温： " + o.toString());
    }

    @Override
    public void update(float temperature) {
        this.temperature = temperature;
        display(temperature);
    }
}
